package com.tyrant.macaulottery.network;

import com.tyrant.macaulottery.banner.StateBean;
import com.tyrant.macaulottery.bean.BannerBean;
import com.tyrant.macaulottery.bean.MessageBean;

import java.util.List;

import io.reactivex.Observable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
import retrofit2.http.GET;

/**
 * Created by zhouwei on 16/11/10.
 */

public class ApiLoader {
    private MovieApi mMovieService;

    public ApiLoader() {
        mMovieService = RetrofitServiceManager.getInstance().create(MovieApi.class);
    }


    public Observable<List<BannerBean>> getBanner() {
        return mMovieService.getBanner()
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    public Observable<List<BannerBean>> getWebHost() {
        return mMovieService.getWebHost()
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    public Observable<List<BannerBean>> getWebBottom() {
        return mMovieService.getWebBottom()
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    public Observable<List<BannerBean>> getAds() {
        return mMovieService.getAds()
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    public Observable<List<MessageBean>> getMessage() {
        return mMovieService.getMessage()
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }


    public Observable<String> testStringexperienceJson() {
        return mMovieService.testStringexperienceJson()
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    public Observable<StateBean> getStateJson() {
        return mMovieService.getStateJson()
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }


    public interface MovieApi {
        //http://heyue.oss-cn-hangzhou.aliyuncs.com/AppData/%E5%8E%9F%E7%94%9F%E5%BD%A9%E7%A5%A8%E6%B4%BB%E5%8A%A8/ads.json
        @GET("banner.json")
        Observable<List<BannerBean>> getBanner();

        @GET("webhost.json")
        Observable<List<BannerBean>> getWebHost();

        @GET("webBottom.json")
        Observable<List<BannerBean>> getWebBottom();

        @GET("ads.json")
        Observable<List<BannerBean>> getAds();

        @GET("message.json")
        Observable<List<MessageBean>> getMessage();

        @GET("ads.json")
        Observable<String> testStringexperienceJson();

        @GET("state.json")
        Observable<StateBean> getStateJson();

    }
}
